package com.example.firstassignment;

import android.os.Bundle;
import android.app.Activity;
import android.content.res.Resources;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class Random extends Activity {
	private TextView display;
	private Button buttonNumberGenerator;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.random);
		
		/* Find text display */
		display = (TextView)findViewById(R.id.displayRandomNumber);
		
		/* Find and Assign listeners to button */
		buttonNumberGenerator = (Button)findViewById(R.id.randomGeneratorButton);
		buttonNumberGenerator.setOnClickListener(new numberGeneratorClick());
	}

	private class numberGeneratorClick implements View.OnClickListener {
		public void onClick(View v){
			
			int randomNumber = (int)( Math.random() * 1000 + 1 );

			
			if (v == buttonNumberGenerator){
				
				display.setText(getResources().getString(R.string.randomNumber)+randomNumber);
			}
			
		}
	}
//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		// Inflate the menu; this adds items to the action bar if it is present.
//		getMenuInflater().inflate(R.menu.main, menu);
//		return true;
//	}

}
